package com.wn.user.mapper;

import com.wn.common.entity.MyParam;
import com.wn.common.pojo.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @BelongsProject: shared_parking
 * @BelongsPackage: com.wn.user.mapper
 * @Author: 廖刚
 * @CreateTime: 2020-06-10 19:54
 * @Description:
 */
@Mapper
public interface UserMapper {



    //动态添加一个用户
    Integer addUser(User user);

    //查询所有用户 支持多条件分页排序查询
    List<User> getAllUser(User user);

    //根据关键字高级检索用户
    List<User> superSearch(@Param("superSearchKeyWord") String superSearchKeyWord);

    //根据关键字高级搜索用户2
    List<User> superSearch2(@Param("superSearchKeyWord") String superSearchKeyWord);

    //出租方用户高级检索
    List<User> superSearch3(@Param("superSearchKeyWord") String superSearchKeyWord);

    //物业方用户高级检索
    List<User> superSearch1(@Param("superSearchKeyWord") String superSearchKeyWord);


    //根据id获取用户对象
    User getUserById(@Param("uId") String uId);

    //通过用户名判断是否存在这样的用户
    Integer existUserByUsername(@Param("username") String username);

    //手机号是否重复
    @Select("select count(0) from user where tel = #{tel}")
    Integer existUserByTel(@Param("tel") String tel);

    //通过id物理删除一个用户对象
    @Delete("delete from user where u_id = #{uId}")
    Integer deleteUserTrueById(@Param("uId") String uId);

    //通过id逻辑删除一个用户对象
    @Update("update user set is_deleted = 1 where u_id = #{uId}")
    Integer deleteUserLogicalById(@Param("uId") String uId);

    //恢复一个被逻辑删除的用户对象
    @Update("update user set is_deleted = 0 where u_id = #{uId}")
    Integer recoverUserById(@Param("uId") String uId);


    //通过id数组 逻辑删除一批用户对象
    Integer deleteSomeUserByIds(String[] uIds);

    //根据id来条件修改一个对象
    Integer updateUser(User user);

    //用户的登录
    User login(User user);

    //根据手机号和新密码修改密码
    @Update("update user set password = #{password} where username = #{username}")
    Integer updatePass(User user);

    //修改用户状态
    @Update("update user set status = #{status} where u_id = #{uId}")
    Integer setUserStatus(User user);

    //根据id获取到用户的电话号
    User getUserByIdTel(@Param("uId") String uId);
}
